﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MessageShark;
using Phoenix.RedisConnectors;
using PServiceBus.Gateway.Interfaces.Commands;
using PServiceBus.Gateway.Redis.Commands;
using PServiceBus.Gateway.Redis.DTO;

namespace PServiceBus.Gateway.Redis {
    internal class RedisSerializationBootstrapper {
        public static void Configure() {

            if (!MessageSharkSerializer.IsTypeRegisterFor<MessageBase>(typeof(RedisBusMessage)))
                MessageSharkSerializer.RegisterTypeFor<MessageBase>(typeof(RedisBusMessage), 3);
            if (!MessageSharkSerializer.IsTypeRegisterFor<MessageBase>(typeof(RedisRouterMessage)))
                MessageSharkSerializer.RegisterTypeFor<MessageBase>(typeof(RedisRouterMessage), 4);


            if (!MessageSharkSerializer.IsTypeRegisterFor<BusMessage>(typeof(RedisBusMessage)))
                MessageSharkSerializer.RegisterTypeFor<BusMessage>(typeof(RedisBusMessage), 1);
            if (!MessageSharkSerializer.IsTypeRegisterFor<RouterMessage>(typeof(RedisRouterMessage)))
                MessageSharkSerializer.RegisterTypeFor<RouterMessage>(typeof(RedisRouterMessage), 2);

            if (!MessageSharkSerializer.IsTypeRegisterFor<IRedisCommand>(typeof(RedisBusMessage)))
                MessageSharkSerializer.RegisterTypeFor<IRedisCommand>(typeof(RedisBusMessage), 1);
            if (!MessageSharkSerializer.IsTypeRegisterFor<IRedisCommand>(typeof(RedisRouterMessage)))
                MessageSharkSerializer.RegisterTypeFor<IRedisCommand>(typeof(RedisRouterMessage), 2);

            if (!MessageSharkSerializer.IsTypeRegisterFor<IRedisCommand>(typeof(RedisESBRequest)))
                MessageSharkSerializer.RegisterTypeFor<IRedisCommand>(typeof(RedisESBRequest), 3);
            if (!MessageSharkSerializer.IsTypeRegisterFor<IRedisCommand>(typeof(RedisRouterRequest)))
                MessageSharkSerializer.RegisterTypeFor<IRedisCommand>(typeof(RedisRouterRequest), 4);

            if (!MessageSharkSerializer.IsTypeRegisterFor<IRedisCommandReply>(typeof(RedisServiceInfos)))
                MessageSharkSerializer.RegisterTypeFor<IRedisCommandReply>(typeof(RedisServiceInfos), 1);
            if (!MessageSharkSerializer.IsTypeRegisterFor<IRedisCommandReply>(typeof(RedisSubscriberInfo)))
                MessageSharkSerializer.RegisterTypeFor<IRedisCommandReply>(typeof(RedisSubscriberInfo), 2);
            if (!MessageSharkSerializer.IsTypeRegisterFor<IRedisCommandReply>(typeof(RedisTopicInfos)))
                MessageSharkSerializer.RegisterTypeFor<IRedisCommandReply>(typeof(RedisTopicInfos), 3);
            if (!MessageSharkSerializer.IsTypeRegisterFor<IRedisCommandReply>(typeof(RedisESBTopicInfo)))
                MessageSharkSerializer.RegisterTypeFor<IRedisCommandReply>(typeof(RedisESBTopicInfo), 4);
        }
    }
}
